import {PageReq} from "@/api/common";
import {TreeNode} from "@/utils/tree";

export interface Category extends TreeNode {
    icon: string,
}

export interface ArticlePageReq extends PageReq {
    userId?: number,
    categoryId?: number,
    titleLike?: string,
    tagId?: number
}

export interface ArticlePageResp {
    id: number,
    title: string,
    summary: string,
    coverImage: string,
    authorId: number,
    authorName: string,
    authorAvatar: string,
    categoryId: number,
    categoryName: string,
    isTop: boolean,
    viewCount: number,
    commentCount: number,
    starCount: number,
    publishedTime: string,
    userProfileVisible: boolean
}

export interface ArticleRecentReq {
    authorId?: number
}

export interface ArticleRecentResp {
    id: number,
    title: string,
    coverImage: string,
    publishedTime: string
}

export interface ArticleCategoryCountReq {
    authorId?: number
}

export interface ArticleCategoryCountResp {
    categoryId: number,
    categoryName: string,
    articleCount: number
}

export interface ArticleDetailResp {
    id: number,
    title: string,
    summary: string,
    content: string,
    authorId: number,
    authorName: string,
    authorAvatar: string,
    categoryId: number,
    categoryName: string,
    viewCount: number,
    commentCount: number,
    starCount: number,
    publishedTime: string,
    hasStar: boolean,
    tags: { tagId: number, tagName: string }[]
}

export interface ArticleStarReq {
    articleId: number
    flag: boolean
}

export interface ArticleCommentPublishReq {
    articleId: number,
    content: string
}

export interface ArticleCommentPageReq extends PageReq {
    articleId: number
}

export interface ArticleCommentPageResp {
    id: number,
    content: string,
    createTime: string,
    userId: number,
    userName: string,
    userAvatar: string,
    showReplyInput?: boolean,
    replying?: boolean,
    replies: ArticleCommentRepliesResp[]
}

export interface ArticleCommentRepliesResp {
    id?: number,
    content: string,
    createTime: string,
    userId: number,
    userName: string,
    userAvatar: string,
    repliedUserName: string,
    showReplyInput?: boolean,
    replying?: boolean,
}

export interface ArticlePublishReq {
    title: string,
    summary: string,
    content: string,
    categoryId: number,
    coverImage?: string,
    tags: string[]
}

export interface ArticleSaveDraftReq {
    title: string,
    summary: string,
    content: string,
    categoryId: number
}

export interface ArticleCommentReplyPublishReq {
    sourceCommentId: number,
    parentReplyId: number,
    repliedUserId: number,
    content: string,
}

export interface ArticleTagCountResp {
    tagId: number,
    tagName: string,
    articleCount: number
}